package com.zs.games.utils;

public class DesensitizationUtil {
    public static String desensitize(String input) {
        int length = input.length();
        if (length <= 2) {
            return input.replaceAll(".", "*");
        } else {
            String firstChar = input.substring(0, 1);
            String lastChar = input.substring(length - 1);
            StringBuilder middlePart = new StringBuilder();
            for (int i = 0; i < length - 2; i++) {
                middlePart.append("*");
            }
            return "!@#" + firstChar + middlePart+ lastChar;
        }
    }

}
